class News < ApplicationRecord
  def icons=(array)
    self[:icons] = array.join(",")
  end

  # 读取时转换回数组
  def icons
    self[:icons].split(",")
  end

  belongs_to :user
  belongs_to :news_category
  has_many :comments, dependent: :destroy
end
